package com.waypolice.manager.controller;

import com.waypolice.base.BaseController;
import com.waypolice.common.utils.StringUtil;
import com.waypolice.manager.service.ArchiveDetailStatisticsService;
import com.waypolice.manager.service.SecretArcStatisticsService;
import com.waypolice.manager.service.SinArcStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by zry on 2019/4/3.
 */
@Controller
@Api(value = "归档明细统计", description = "审计档案归档明细统计")
@RequestMapping(value = "/pcwindow")
public class SecretArcStatisticsController extends BaseController{

    private static final Logger LOGGER = LoggerFactory.getLogger(SecretArcStatisticsController.class);


    @Autowired
    private SecretArcStatisticsService secretArcStatisticsService;


    @ApiOperation(value = "秘密档案归档明细统计首页")
    @RequestMapping(value = "/secretArc", method = RequestMethod.GET)
    public String sinArcJump() {
        return "/countManager/secretArcstatistics";
    }

    @ApiOperation(value = "秘密档案统计明细")
    @RequestMapping(value = "/secretArcStatisticsDetail")
    @ResponseBody
    public Object secretArcStatisticsDetail( @RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
                                    @RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
                                    @RequestParam(required = false, defaultValue = "", value = "search") String search,
                                    @RequestParam(required = false, value = "sort") String sort,
                                    @RequestParam(required = false, value = "order") String order,
                                    HttpServletRequest request,String flag) {
        Object secretArcStatistics = null;
        String vol_archive_unit=request.getParameter("VOL_ARCHIVE_UNIT");
        String vol_archive_year=request.getParameter("VOL_ARCHIVE_YEAR");
        String vol_storage_time=request.getParameter("VOL_STORAGE_TIME");
        String vol_secret=request.getParameter("VOL_SECRET");
        String starttime=request.getParameter("starttime");
        String endtime=request.getParameter("endtime");
        if(null==flag||flag.equals("0")){
            //初始化查询
            secretArcStatistics =secretArcStatisticsService.getSecretArchiveDetailStatistics(offset, limit);
        }else{
            //条件查询
            secretArcStatistics =secretArcStatisticsService.getSecretPostArchiveDetailStatistics(offset, limit,vol_archive_unit,vol_archive_year,vol_storage_time,vol_secret,starttime,endtime);
        }
        return secretArcStatistics;
    }
}